<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>
<body>
    <script>
        var arr=[1,2,3,4,5,6,7,8,9,10,11]
        /* [[1,2,3],[4,5,6],[7,8,9]] */
       /* 1.Math.ceil(arr.length/3) --确定数组分割几次*/
       /* 2.slice  123  0--3  0*3  (0+1)*3  i*3  (i+1)*3
                   456  3--6  1*3  (1+1)*3 
                   789  6--9  2*3  (1+2)*3  
        */
        var sum=[]
       /*  for(var i=0;i<Math.ceil(arr.length/3);i++){
            let item=arr.slice(i*3,(i+1)*3)
            sum.push(item)
        }
        console.log(sum) */

        for(var i=0;i<arr.length;i+=3){
            let item=arr.slice(i,i+3)
            sum.push(item)
        }
        console.log(sum)
    </script>
</body>
</html>